home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / Resources / CutePDF 2.3 / converter.exe / GNUGS / PRINTAFM.PS < prev    next >
Text File  |  2002-04-11  |  3KB  |  150 lines

  1. %!
  2. % written by James Clark <jjc@jclark.uucp>
  3.  
  4. % print an afm file on the standard output
  5. % usage is `fontname printafm' eg `/Times-Roman printafm'
  6.  
  7. % From the `dvitops' distribution, which included this notice:
  8. % dvitops is not copyrighted; you can do with it exactly as you please.
  9. % I would, however, ask that if you make improvements or modifications,
  10. % you ask me before distributing them to others.
  11.  
  12. % Altered by d.love@dl.ac.uk to produce input for Rokicki's afm2tfm,
  13. % which groks the format of the Adobe AFMs.
  14.  
  15. % $Id: printafm.ps,v 1.1.6.1 2002/04/10 09:22:58 giles Exp $
  16.  
  17. % Modified by L. Peter Deutsch 9/14/93:
  18. %   uses Ghostscript's =only procedure to replace 'buf cvs print'.
  19. % Modified by L. Peter Deutsch 9/6/95:
  20. %   uses Ghostscript's shellarguments facility to accept the font name
  21. %     on the command line.
  22.  
  23. /onechar 1 string def
  24.  
  25. % c toupper - c
  26. /toupper {
  27.     dup dup 8#141 ge exch 8#172 le and { 
  28.         8#40 sub
  29.     } if
  30. } bind def
  31.  
  32. % printcharmetrics -
  33.  
  34. /printcharmetrics {
  35.     (StartCharMetrics ) print
  36.     currentfont /CharStrings get dup length exch /.notdef known { 1 sub } if =
  37.     currentfont 1000 scalefont setfont 0 0 moveto
  38.     /e currentfont /Encoding get def
  39.     0 1 255 {
  40.         dup e exch get
  41.         dup /.notdef ne {
  42.             exch dup printmetric
  43.         } {
  44.             pop pop
  45.         } ifelse
  46.     } for
  47.     % s contains an entry for each name in the original encoding vector
  48.     /s 256 dict def
  49.     e {
  50.         s exch true put
  51.     } forall
  52.     % v is the new encoding vector
  53.     /v 256 array def
  54.     0 1 255 {
  55.         v exch /.notdef put
  56.     } for
  57.     % fill up v with names in CharStrings
  58.     /i 0 def
  59.     currentfont /CharStrings get {
  60.         pop
  61.         i 255 le {
  62.             v i 3 -1 roll put
  63.             /i i 1 add def
  64.         } {
  65.             pop
  66.         } ifelse
  67.     } forall
  68.     % define a new font with v as its encoding vector
  69.     currentfont maxlength dict /f exch def
  70.     currentfont {
  71.         exch dup dup /FID ne exch /Encoding ne and { 
  72.             exch f 3 1 roll put
  73.         } { 
  74.             pop pop 
  75.         } ifelse
  76.     } forall
  77.     f /Encoding v put
  78.     f /FontName /temp put
  79.     % make this new font the current font
  80.     /temp f definefont setfont
  81.     % print a entry for each character not in old vector
  82.     /e currentfont /Encoding get def
  83.     0 1 255 {
  84.         dup e exch get
  85.         dup dup /.notdef ne exch s exch known not and { 
  86.             exch -1 printmetric
  87.         } { 
  88.             pop pop
  89.         } ifelse
  90.     } for
  91.     (EndCharMetrics) =
  92. } bind def
  93.  
  94. % name actual_code normal_code printmetric -
  95.  
  96. /printmetric {
  97.     /saved save def
  98.     (C ) print =only
  99.     ( ; WX ) print
  100.     onechar 0 3 -1 roll put
  101.     onechar stringwidth pop round cvi =only
  102.     ( ; N ) print =only
  103.     ( ; B ) print
  104.     onechar false charpath flattenpath mark pathbbox counttomark {
  105.         counttomark -1 roll
  106.         round cvi =only
  107.         ( ) print
  108.     } repeat pop
  109.     (;) =
  110.     saved restore
  111. } bind def
  112.  
  113. % fontname printafm -
  114.  
  115. /printafm {
  116.     findfont gsave setfont
  117.     (StartFontMetrics 2.0) =
  118.     (FontName ) print currentfont /FontName get =
  119.  
  120.         % Print the FontInfo
  121.  
  122.     currentfont /FontInfo get {
  123.         exch
  124.         =string cvs dup dup 0 get 0 exch toupper put print
  125.         ( ) print =
  126.     } forall
  127.  
  128.         % Print the FontBBox
  129.  
  130.     (FontBBox) print
  131.     currentfont /FontBBox get {
  132.         ( ) print round cvi =only
  133.     } forall
  134.     (\n) print
  135.  
  136.     printcharmetrics
  137.     (EndFontMetrics) =
  138.     grestore
  139. } bind def
  140.  
  141. % Check for command line arguments.
  142. [ shellarguments
  143.  { ] dup length 1 eq
  144.     { 0 get printafm }
  145.     { (Usage: printafm fontname\n) print flush }
  146.    ifelse
  147.  }
  148.  { pop }
  149. ifelse
  150.